<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01-数组-splice</title>
</head>
<body>
    <script>
        /* 
        splice()
        方法可通过指定的索引号和个数，提取数组的某个部分
        语法：
            数组名.splice(start[,number]);
            start   (必需)：规定开始选取的索引号
            number  (可选)：元素的个数
        注意：原数组受到影响
        */

        let arr = ['张飞0', '关羽1', '刘备2', '猴子3', '黑鸟4', '剑圣5'];
        let arr2 = arr.splice(2,2);
        console.log(arr2);  //['刘备2', '猴子3']
        // 原数组受到影响
        let arr3 = arr.splice(2);  //['黑鸟4', '剑圣5']
        console.log(arr3);

        console.log(arr);  //['张飞0', '关羽1']

        
         
    </script>
</body>
</html>